<div class="content">
    {% if team_assignment %}
        <h3>Team: {{ team_members }}</h3><br />
    {% endif %}

    {% if hide_version_and_test_details == false %}
        <h3 class='label' id="submission_header" style="float: left">Select Submission Version:</h3>
        {% include 'grading/VersionChoice.twig' with({
            'on_change': "versionChange('" ~ view_version_url ~ "', this)"
        }) %}

        {# If viewing the active version, show cancel button, otherwise so button to switch active #}
        {% if display_version > 0 %}
            {% if display_version == active_version %}
                <form style="display: inline;" method="post"
                      action="{{ cancel_url }}">
                    <input type='hidden' name="csrf_token" value="{{ csrf_token }}" />
                    <input type="submit" id="do_not_grade" class="btn btn-default" style="float: right" value="Do Not Grade This Assignment">
                </form>
            {% else %}
                <form style="display: inline;" method="post"
                      onsubmit='return checkVersionChange({{ display_version_days_late }},{{ allowed_late_days }})'
                      action="{{ change_version_url }}">
                    <input type='hidden' name="csrf_token" value="{{ csrf_token }}" />
                    <input type="submit" id="version_change" class="btn btn-primary" value="Grade This Version">
                </form>
            {% endif %}
        {% endif %}
        {# /Switch version button #}

        {# disable changing submissions or cancelling assignment if student submit not allowed #}
        {% if not can_change_submissions %}
            <script type="text/javascript">
                $(function() {
                    $("#do_not_grade").prop("disabled", true);
                    $("#version_change").prop("disabled", true);
                });
            </script>
        {% endif %}

        {# disable looking at other submissions if student any version not allowed #}
        {% if not can_see_all_versions %}
            <script type="text/javascript">
                $(function() {
                    $('select[name=submission_version]').hide();
                    $('#do_not_grade').hide();
                    $('#version_change').hide();
                    $('#submission_header').hide();
                    $('#submission_message').hide();
                });
            </script>
        {% endif %}

        <div class="sub submission-message">
            {% if active_version == 0 and display_version == 0 %}
                <p class="red-message">
                    Note: You have selected to NOT GRADE THIS ASSIGNMENT.<br />
                    This assignment will not be graded by the instructor/TAs and a zero will be recorded in the gradebook.<br />
                    You may select any version above and press "Grade This Version" to re-activate your submission for grading.<br />
                </p>
            {% elseif not active_same_as_graded and has_manual_grading %}
                <p class="red-message">
                    Note: The version you have selected to be graded is not the version graded by the instructor/TAs.<br />
                    If the graded version does not match your selected version, a zero will be recorded in the gradebook.
                </p>
            {% elseif active_version > 0 and active_version == display_version %}
                <p class="green-message">
                    Note: This version of your assignment will be graded by the instructor/TAs and the score recorded in the gradebook.
                </p>
            {% elseif active_version > 0 %}
                <p class="red-message">
                    Note: This version of your assignment will not be graded the instructor/TAs. <br />
                    Click the button "Grade This Version" if you would like to specify that this version of your homework should be graded.
                </p>
            {% else %}
                <p class="red-message">
                    Note: You have selected to NOT GRADE THIS ASSIGNMENT.<br />
                    This assignment will not be graded by the instructor/TAs and a zero will be recorded in the gradebook.<br />
                    Click the button "Grade This Version" if you would like to specify that this version of your homework should be graded.
                </p>
            {% endif %}
        </div>
    {% endif %}

    {% if active_version != 0 or display_version != 0 %}
        {% include 'submission/homework/CurrentVersionResults.twig' %}
    {% endif %}
</div>